#!/bin/bash
LCELIA_DIR=$HOME/NewPCloudSvn/ABEAccessControl/src/libcelia
LKPABE_DIR=$HOME/NewPCloudSvn/ABEAccessControl/src/libkpabe
INC_GLIB=/usr/include/glib-2.0
#LIB_GLIB=/opt/local/lib
INC_PBC=$HOME/NewPCloudSvn/ABEAccessControl/src/pbc-0.5.13/include
if ! [ -d $LCELIA_DIR ]; then
	echo "LibCelia not found, LCELIA_DIR not set"
	exit 1;	
fi

if ! [ -d $LKPABE_DIR ]; then
	echo "LibKpABE not found, LKPABE_DIR not set"
	exit 1;
fi

if ! [ -d $INC_GLIB ]; then
	echo "Glib not found, INC_GLIB not set"
	exit 1;
fi

if ! [ -d $LIB_GLIB ]; then
	echo Glib not found, LIB_GLIB not set
	exit 1;
fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_GLIB
export LIBRARY_PATH=$LIB_GLIB

if ! [ -d $INC_PBC ]; then
	echo "PBC not found, INC_PBC not set"
	exit 1;
fi

if ! [ -d $JAVA_HOME ]; then
	echo "Java not found, JAVA_HOME not set"
	exit 1;
fi
#temp=`echo $JAVA_HOME | sed 's:/Home::g'`
#INC_JAVA=$temp/Headers
#INC_JAVA=/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers
g++ -c -fPIC -g -I $INC_GLIB -I $JAVA_HOME/include -I $JAVA_HOME/include/linux -I $INC_PBC -I $LCELIA_DIR -I $LKPABE_DIR kpabe_owner.cc kpabe_cloud.cc kpabe_user.cc utils.cc

g++ -shared -o libproxyKPAbe.so *.o $LCELIA_DIR/*.o $LKPABE_DIR/common.o $LKPABE_DIR/policy_lang.o -lpbc -lglib-2.0 -lgmp -lcrypto

#g++ -o test *.o $LCELIA_DIR/*.o $LKPABE_DIR/common.o $LKPABE_DIR/policy_lang.o -lpbc -lglib-2.0 -lgmp -lcrypto
